#include <iostream>
using namespace std;

//https://www.nowcoder.com/practice/9b969a3ec20149e3b870b256ad40844e?tpId=230&tqId=39751&ru=/exam/oj

const int N = 1e5 + 10;
int n;
int cost[N], dp[N];

int main()
{
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> cost[i];

    for (int i = 2; i <= n; i++)
        dp[i] = min(dp[i - 1] + cost[i - 1], dp[i - 2] + cost[i - 2]);

    cout << (n == 1 ? cost[0] : dp[n]) << endl;

    return 0;
}
